package com.aspose.cells;

import java.util.ArrayList;

public class OleObject extends Shape {
   private boolean a = false;
   private byte b = 1;
   private byte[] c;
   private boolean d;
   private String e;
   private int A = 255;
   private boolean B;
   private String C;
   private int D = -1;
   private int E;
   private com.aspose.cells.b.a.zh F;
   private byte G = 0;
   private static final com.aspose.cells.b.c.a.za H = new com.aspose.cells.b.c.a.za(new String[]{".wav", "Acrobat Document"});

   OleObject(ShapeCollection shapes) {
      super(shapes, 24, shapes);
      this.F = com.aspose.cells.b.a.zh.a;
      this.N().c().a(267, 0, 1);
   }

   boolean a() {
      return this.a;
   }

   void a(boolean var1) {
      this.a = var1;
   }

   byte b() {
      return this.b;
   }

   void a(byte var1) {
      this.b = var1;
   }

   public boolean isAutoSize() {
      return (this.b & 255 & 1) != 0;
   }

   public void setAutoSize(boolean value) {
      if (value) {
         this.b = (byte)(this.b | 1);
      } else {
         this.b = (byte)(this.b & 254);
      }

   }

   public boolean isLink() {
      return (this.b & 255 & 2) == 2;
   }

   public void setLink(boolean value) {
      if (value) {
         this.b = (byte)(this.b | 2);
      } else {
         this.b = (byte)(this.b & 253);
      }

   }

   boolean c() {
      return this.isLink() && this.D != -1;
   }

   public boolean getDisplayAsIcon() {
      return (this.b & 255 & 8) != 0;
   }

   public void setDisplayAsIcon(boolean value) {
      if (value) {
         this.b = (byte)(this.b | 8);
      } else {
         this.b = (byte)(this.b & 247);
      }

   }

   zcb d() {
      return this.e() > 0 ? this.L().Q().b().a(this.e() - 1) : null;
   }

   int e() {
      return this.N().c().c(16644, 0);
   }

   void a(int var1) {
      this.N().c().a(16644, 0, var1);
   }

   public byte[] getImageData() {
      zcb var1 = this.d();
      return var1 == null ? null : var1.b();
   }

   public byte[] getObjectData() {
      return this.c;
   }

   public void setObjectData(byte[] value) {
      this.c = value;
   }

   public String getImageSourceFullName() {
      return (this.f() & 10) != 0 ? this.N().c().e(49413) : null;
   }

   public void setImageSourceFullName(String value) {
      this.N().c().a(49413, 2, value);
      this.b(14);
      if (this.N().c().c(16644) != null) {
         this.d().j();
         this.N().c().b(16644);
      }

   }

   int f() {
      return this.N().c().c(262, 0);
   }

   void b(int var1) {
      this.N().c().a(262, 0, var1);
   }

   boolean g() throws Exception {
      this.u();
      return FileFormatUtil.d(this.A);
   }

   byte[] h() throws Exception {
      zvh var1;
      com.aspose.cells.b.a.d.zh var2;
      com.aspose.cells.b.a.d.zh var3;
      if (this.l()) {
         var1 = new zvh(this.F);
         var2 = new com.aspose.cells.b.a.d.zh(this.j());
         var1.a().a("\u0001Ole10Native", var2);
         var3 = new com.aspose.cells.b.a.d.zh();
         var1.a((com.aspose.cells.b.a.d.zm)var3);
         return var3.o();
      } else if (this.g()) {
         return this.c;
      } else if (zakq.a(this.c)) {
         return this.c;
      } else {
         var1 = new zvh(this.F);
         var2 = new com.aspose.cells.b.a.d.zh(this.c);
         var1.a().a("CONTENTS", var2);
         var3 = new com.aspose.cells.b.a.d.zh();
         var1.a((com.aspose.cells.b.a.d.zm)var3);
         return var3.o();
      }
   }

   void a(byte[] var1) throws Exception {
      this.c = var1;
      if (zakq.a(var1)) {
         com.aspose.cells.b.a.d.zh var2 = new com.aspose.cells.b.a.d.zh(var1);
         zvh var3 = new zvh(var2);
         FileFormatInfo var4 = FileFormatUtil.a((String)null, (com.aspose.cells.b.a.d.zm)null, var3.a());
         zane var5 = var3.a();
         this.a(var5.a());
         this.setFileFormatType(var4.getFileFormatType());
         this.a = false;
         switch(var4.getFileFormatType()) {
         case 31:
            var5.g("\u0001Ole");
            break;
         case 35:
            var2 = var5.a("\u0001Ole10Native");
            this.d = true;
            this.a(var2);
            break;
         case 255:
            var2 = var5.a("CONTENTS");
            if (var2 != null) {
               this.c = var2.o();
            }
         }
      }

   }

   boolean i() {
      switch(this.b) {
      case 0:
      case 1:
      case 5:
      case 8:
      case 9:
         return true;
      case 2:
      case 4:
      case 6:
      case 7:
      default:
         return false;
      case 3:
         return !this.a || this.e != null && "Equation".equals(this.e);
      }
   }

   byte[] j() {
      if (this.C != null && !"".equals(this.C)) {
         String var9 = this.C;
         int var10 = var9.lastIndexOf(92);
         String var3 = var9.substring(var10 + 1);
         byte[] var4 = Encoding.getDefault().a(var3);
         byte[] var5 = Encoding.getDefault().a(this.C);
         int var6 = var5.length * 2 + var4.length + 19 + this.c.length;
         byte[] var7 = new byte[var6 + 4];
         System.arraycopy(com.aspose.cells.b.a.zc.a(var6), 0, var7, 0, 4);
         byte var8 = 4;
         var7[var8] = 2;
         int var11 = var8 + 2;
         System.arraycopy(var4, 0, var7, var11, var4.length);
         var11 += var4.length + 1;
         System.arraycopy(var5, 0, var7, var11, var5.length);
         var11 += var5.length + 1;
         var7[var11 + 2] = 3;
         var11 += 4;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var5.length + 1), 0, var7, var11, 4);
         var11 += 4;
         System.arraycopy(var5, 0, var7, var11, var5.length);
         var11 += var5.length + 1;
         System.arraycopy(com.aspose.cells.b.a.zc.a(this.c.length), 0, var7, var11, 4);
         var11 += 4;
         System.arraycopy(this.c, 0, var7, var11, this.c.length);
         return var7;
      } else if (this.c != null && this.c.length != 0) {
         int var1 = this.c.length;
         byte[] var2 = new byte[var1 + 4];
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1), 0, var2, 0, 4);
         System.arraycopy(this.c, 0, var2, 4, this.c.length);
         return var2;
      } else {
         return new byte[0];
      }
   }

   void a(com.aspose.cells.b.a.d.zh var1) throws Exception {
      byte[] var2 = var1.o();
      if (var2.length != 0) {
         int var3 = com.aspose.cells.b.a.zc.a(var2, 0);
         short var4 = com.aspose.cells.b.a.zc.b(var2, 4);
         if (var4 != 2) {
            byte[] var11 = new byte[var3];
            System.arraycopy(var2, 4, var11, 0, var3);
            this.c = var11;
         } else {
            byte var5 = 6;
            int[] var6 = new int[]{var5};
            a(var2, var6);
            int var10 = var6[0];
            var6[0] = var10;
            this.C = a(var2, var6);
            var10 = var6[0];
            var10 += 8;
            var6[0] = var10;
            b(var2, var6);
            var10 = var6[0];
            int var8 = com.aspose.cells.b.a.zc.a(var2, var10);
            var10 += 4;
            byte[] var9 = new byte[var8];
            System.arraycopy(var2, var10, var9, 0, var8);
            this.c = var9;
         }
      }
   }

   static String a(byte[] var0, int[] var1) {
      int var2 = var1[0];
      boolean var3 = false;

      int var10001;
      do {
         if ((var0[var1[0]] & 255) > 127) {
            var3 = true;
         }

         int var10004 = var1[0];
         var10001 = var1[0];
         var1[0] = var10004 + 1;
      } while((var0[var10001] & 255) != 0);

      if (var3) {
         return Encoding.getDefault().a(var0, var2, var1[0] - var2 - 1);
      } else {
         return Encoding.getASCII().a(var0, var2, var1[0] - var2 - 1);
      }
   }

   static void b(byte[] var0, int[] var1) {
      int var10001;
      do {
         int var10004 = var1[0];
         var10001 = var1[0];
         var1[0] = var10004 + 1;
      } while((var0[var10001] & 255) != 0);

   }

   boolean k() {
      return this.d;
   }

   void b(boolean var1) {
      this.d = true;
   }

   boolean l() throws Exception {
      if (this.d) {
         return true;
      } else if (this.isLink()) {
         return false;
      } else {
         if (this.C == null || "".equals(this.C)) {
            switch(this.getFileFormatType()) {
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
            case 13:
            case 16:
            case 22:
            case 23:
            case 24:
            case 25:
            case 26:
            case 27:
            case 31:
            case 32:
            case 38:
            case 39:
            case 40:
            case 41:
            case 42:
            case 43:
            case 44:
            case 45:
            case 255:
               break;
            default:
               String var1 = FileFormatUtil.a(this.getFileFormatType(), ".bin");
               if (!".bin".equals(var1)) {
                  this.C = "oleObject" + this.E + var1;
                  this.d = true;
                  this.setProgID("Package");
                  this.a(new com.aspose.cells.b.a.zh("0003000c-0000-0000-c000-000000000046"));
               }
            }
         }

         return this.d;
      }
   }

   public void setNativeSourceFullName(String sourceFullName) throws Exception {
      this.C = sourceFullName;
      this.d = true;
      this.a(new com.aspose.cells.b.a.zh("0003000c-0000-0000-c000-000000000046"));
      this.setProgID("Package");
      this.setFileFormatType(FileFormatUtil.a(com.aspose.cells.b.a.d.zk.d(sourceFullName), 255));
   }

   public String getProgID() throws Exception {
      this.u();
      return this.e;
   }

   public void setProgID(String value) {
      this.e = value;
      this.G = (byte)(this.G | 4);
   }

   public int getFileFormatType() throws Exception {
      this.u();
      return this.A;
   }

   public void setFileFormatType(int value) {
      this.A = value;
      this.G = (byte)(this.G | 1);
   }

   /** @deprecated */
   public int getFileType() {
      switch(this.A) {
      case 5:
         return 0;
      case 6:
         return 6;
      case 7:
      case 8:
      case 9:
      case 10:
      case 11:
      case 12:
      case 14:
      case 15:
      case 17:
      case 18:
      case 19:
      case 20:
      case 21:
      case 22:
      case 23:
      case 24:
      case 25:
      case 28:
      case 29:
      case 30:
      case 35:
      case 36:
      case 37:
      default:
         return 10;
      case 13:
         return 3;
      case 16:
         return 7;
      case 26:
      case 41:
      case 42:
      case 43:
      case 44:
      case 45:
         return 9;
      case 27:
      case 38:
      case 39:
      case 40:
         return 8;
      case 31:
         return 1;
      case 32:
         return 2;
      case 33:
         return 5;
      case 34:
         return 4;
      }
   }

   /** @deprecated */
   public void setFileType(int value) {
      switch(value) {
      case 0:
         this.setFileFormatType(5);
         break;
      case 1:
         this.setFileFormatType(31);
         break;
      case 2:
         this.setFileFormatType(32);
         break;
      case 3:
         this.setFileFormatType(13);
         break;
      case 4:
         this.setFileFormatType(34);
         break;
      case 5:
         this.setFileFormatType(33);
         break;
      case 6:
         this.setFileFormatType(6);
         break;
      case 7:
         this.setFileFormatType(16);
         break;
      case 8:
         this.setFileFormatType(27);
         break;
      case 9:
         this.setFileFormatType(26);
      }

   }

   int m() {
      if (this.isLink() && this.D == -1) {
         WorksheetCollection var1 = this.J().i();
         zbqf var2 = var1.v();

         for(int var3 = 0; var3 < var2.getCount(); ++var3) {
            zbqg var4 = var2.a(var3);
            if (var4.a() == 4) {
               ArrayList var5 = var4.b();
               if (var5 != null && var5.size() >= 1) {
                  for(int var6 = 0; var6 < var5.size(); ++var6) {
                     int var7 = ((zuk)var5.get(var6)).c();
                     if (var7 == this.E) {
                        this.D = this.L().q().a(var3, 65534, 65534, true);
                     }
                  }
               }
            }
         }
      }

      return this.D;
   }

   void c(int var1) {
      this.D = var1;
   }

   int n() {
      int var1 = this.L().q().c(this.D);
      zbqg var2 = this.L().v().a(var1);

      for(int var3 = 0; var3 < var2.b().size(); ++var3) {
         zuk var4 = (zuk)var2.b().get(var3);
         if (var4.c() == this.E) {
            return var3;
         }
      }

      return -1;
   }

   void d(int var1) {
      int var2 = this.L().q().c(this.D);
      zbqg var3 = this.L().v().a(var2);
      zuk var4 = (zuk)var3.b().get(var1);
      this.E = var4.c();
      String var5 = null;
      String var6 = null;
      String[] var7 = new String[]{var5};
      String[] var8 = new String[]{var6};
      var3.a(var7, var8);
      var5 = var7[0];
      var6 = var8[0];
      this.setProgID(var5);
      this.C = var6;
   }

   void a(String var1) throws Exception {
      WorksheetCollection var2 = this.j.i();
      int var3 = var2.v().a(this.e, var1, true);
      zbqg var4 = var2.v().a(var3);
      int var5 = var2.q().a(var3, 65534, 65534, true);
      this.D = var5;
      this.C = var4.k();
      if (var4.a() == 4) {
         if (var2.f() == null) {
            var2.a(new zvh(WorksheetCollection.h));
         }

         zuk var6;
         if (var4.b().size() == 0) {
            var6 = new zuk(var4);
            var6.a("'");
            com.aspose.cells.b.a.a.ze.a(var4.b(), (Object)var6);
            var6.b(this.E);
            var6.d(86);
            String var7 = "LNK" + com.aspose.cells.a.c.zp.e(this.E);
            com.aspose.cells.b.a.d.zh var8 = new com.aspose.cells.b.a.d.zh();
            var2.f().a().a(var7, var8);
         } else {
            var6 = (zuk)var4.b().get(0);
            this.E = var6.c();
            var6.d(var6.g() | 16);
         }
      }

   }

   public String getObjectSourceFullName() {
      return this.C;
   }

   public void setObjectSourceFullName(String value) throws Exception {
      this.C = value;
      if (this.A == 255) {
         this.setFileFormatType(FileFormatUtil.a(com.aspose.cells.b.a.d.zk.d(value), 255));
         switch(this.getFileFormatType()) {
         case 1:
         case 11:
         case 12:
         case 14:
         case 15:
         case 17:
         case 20:
         case 21:
         case 28:
         case 30:
         case 33:
         case 34:
         case 35:
         case 37:
         case 255:
            switch(H.a(com.aspose.cells.b.a.d.zk.d(value).toLowerCase())) {
            case 0:
               this.d = true;
               this.setProgID("Sound Recorder Document");
               this.b = 9;
               this.a(new com.aspose.cells.b.a.zh("0003000d-0000-0000-c000-000000000046"));
               return;
            default:
               this.C = value;
               this.d = true;
               this.setProgID("Package");
               this.a(new com.aspose.cells.b.a.zh("0003000c-0000-0000-c000-000000000046"));
               return;
            }
         case 5:
            this.C = value;
            this.setProgID("Excel.Sheet.8");
            if (this.isLink() && this.getObjectData() == null) {
               if (this.a) {
                  this.O().a = null;
               }

               this.a(value);
            }

            this.a = false;
            break;
         case 13:
            if (this.isLink() && this.getObjectData() == null) {
               if (this.a) {
                  this.O().a = null;
               }

               this.a(value);
               this.a = false;
            } else {
               this.C = null;
            }
         }

      }
   }

   /** @deprecated */
   public String getSourceFullName() {
      return this.C;
   }

   /** @deprecated */
   public void setSourceFullName(String value) throws Exception {
      this.setObjectSourceFullName(value);
   }

   void b(String var1) {
      this.C = var1;
   }

   int o() {
      int var1 = this.m();
      return var1 != -1 ? this.L().q().c(var1) : -1;
   }

   String p() {
      if (this.isLink()) {
         int var1 = this.o();
         if (var1 == -1) {
            return null;
         } else {
            WorksheetCollection var2 = this.J().i();
            zbqf var3 = var2.v();
            var1 += var2.u() > var1 ? 1 : 0;
            return "[" + var1 + "]!''''";
         }
      } else {
         return null;
      }
   }

   void c(String var1) throws Exception {
      this.a = true;
      int var2 = var1.indexOf("]");
      if (var2 == -1) {
         this.C = var1;
      } else {
         String var3 = var1.substring(1, 1 + (var2 - 1));
         if (!zapb.c(var3)) {
            this.C = var1;
         } else {
            this.b = 3;
            int var4 = com.aspose.cells.b.a.zo.a(var3);
            WorksheetCollection var5 = this.j.i();
            zbqg var6 = var5.v().a(var4);
            this.C = var6.k();
            this.D = this.L().q().a(var4, 65534, 65534, true);
            if (var6.a() == 4) {
               if (var5.f() == null) {
                  var5.a(new zvh(WorksheetCollection.h));
               }

               com.aspose.cells.b.a.d.zh var7 = new com.aspose.cells.b.a.d.zh();
               String var8 = "LNK" + com.aspose.cells.a.c.zp.e(this.E);
               var5.f().a().a(var8, var7);
               zuk var9;
               if (var6.b().size() == 0) {
                  var9 = new zuk(var6);
                  var9.a("'");
                  com.aspose.cells.b.a.a.ze.a(var6.b(), (Object)var9);
                  var9.b(this.E);
                  var9.d(86);
               } else {
                  var9 = (zuk)var6.b().get(0);
                  var9.b(this.E);
                  var9.d(var9.g() | 16);
               }
            }

         }
      }
   }

   byte[] q() {
      byte[] var1 = new byte[15];
      var1[0] = 7;
      var1[4] = 89;
      int var2 = this.D;
      int var3 = this.n();
      System.arraycopy(com.aspose.cells.b.a.zc.a(var2), 0, var1, 5, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(var3 + 1), 0, var1, 7, 2);
      return var1;
   }

   void b(byte[] var1) throws Exception {
      WorksheetCollection var2 = this.L();
      byte var4 = 5;
      int var5 = com.aspose.cells.b.a.zc.e(var1, var4) & '\uffff';
      this.D = var5;
      int var6 = this.L().q().c(var5);
      zbqg var7 = this.L().v().a(var6);
      int var12 = var4 + 2;
      int var8 = com.aspose.cells.b.a.zc.e(var1, var12) & '\uffff';
      zuk var9 = (zuk)var7.b().get(var8 - 1);
      if (var7.a() == 4) {
         if (var2.f() == null) {
            var2.a(new zvh(WorksheetCollection.h));
         }

         com.aspose.cells.b.a.d.zh var10 = new com.aspose.cells.b.a.d.zh();
         String var11 = "LNK" + com.aspose.cells.a.c.zp.e(this.E);
         var2.f().a().a(var11, var10);
         var9.b(this.E);
         var9.d(var9.g() | 16);
      }

   }

   boolean r() {
      return this.B;
   }

   void c(boolean var1) {
      this.B = var1;
   }

   int s() {
      return this.E;
   }

   void e(int var1) {
      this.E = var1;
   }

   com.aspose.cells.b.a.zh t() throws Exception {
      this.u();
      return this.F;
   }

   void a(com.aspose.cells.b.a.zh var1) {
      this.F = var1;
      this.G = (byte)(this.G | 2);
   }

   void u() throws Exception {
      if (this.G != 7) {
         FileFormatInfo var1 = null;
         if ((this.G & 255 & 1) == 0) {
            if (this.C != null && this.C != null) {
               this.setFileFormatType(FileFormatUtil.a(com.aspose.cells.b.a.d.zk.d(this.C), 255));
            } else if (this.c != null) {
               com.aspose.cells.b.a.d.zh var2 = new com.aspose.cells.b.a.d.zh(this.c);

               try {
                  var1 = FileFormatUtil.a((com.aspose.cells.b.a.d.zm)var2);
                  this.setFileFormatType(var1.getFileFormatType());
               } finally {
                  if (var2 != null) {
                     var2.a();
                  }

               }
            } else {
               this.setFileFormatType(255);
            }

            if (this.A == 255) {
               if ((this.G & 255 & 2) != 0 && this.t().equals(FileFormatUtil.a(13))) {
                  this.setFileFormatType(13);
               }

               if (this.A == 255 && this.e != null && !"".equals(this.e)) {
                  switch(H.a(this.e)) {
                  case 1:
                     this.setFileFormatType(13);
                  }
               }
            }
         }

         if ((this.G & 255 & 2) == 0) {
            if (var1 != null && var1.d != null) {
               this.a(var1.d);
            }

            if (com.aspose.cells.b.a.zh.a(this.F, com.aspose.cells.b.a.zh.a)) {
               this.a(FileFormatUtil.a(this.A));
            }
         }

         if ((this.G & 255 & 4) == 0) {
            this.setProgID(FileFormatUtil.c(this.A));
         }

      }
   }

   void a(OleObject var1, CopyOptions var2) {
      super.a((Shape)var1, (CopyOptions)var2);
      boolean var3 = var1.L() == this.L();
      this.b = var1.b;
      this.F = var1.F;
      this.a = var1.a;
      this.e = var1.e;
      this.G = var1.G;
      ++this.L().c;
      this.E = this.L().c;
      this.B = var1.B;
      if (var2.a || var1.isLink() || var1.c == null || var1.k()) {
         this.C = var1.C;
      }

      this.d = var1.d;
      this.A = var1.A;
      this.a(this.L().Q().b().a(var1.d(), var1.e(), var3));
      if (var1.c != null) {
         this.c = new byte[var1.c.length];
         System.arraycopy(var1.c, 0, this.c, 0, this.c.length);
      }

   }

   public ImageFormat getImageFormat() throws Exception {
      zcb var1 = this.d();
      return var1 != null && var1.f() != null && var1.f().e() != null ? var1.a() : ImageFormat.getBmp();
   }
}
